/*
 * Copyright 2011 derek.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aocore.item;

/**
 *
 * @author derek
 */
public enum ItemCategory
{
    Helm(0),
    Armor(1),
    /// <summary>
    /// Most weapons, including Crossbows
    /// </summary>
    Weapon(5),
    /// <summary>
    /// Bows (not crossbows), sometimes shield (if equipped in LeftHand?)
    /// </summary>
    Weapon2(6),
    /// <summary>
    /// Shields can some sometimes be Weapon2...
    /// </summary>
    Shield(7),
    /// <summary>
    /// Class specific items !?
    /// </summary>
    Special(10),
    /// <summary>
    /// BaseMiscItems and gloves, boots...
    /// </summary>
    Misc(16);

    private final int id;

    private ItemCategory(int id)
    {
        this.id = id;
    }

    public int getId()
    {
        return id;
    }

    public boolean isArmor()
    {
        return this == Helm || this == Armor  || this == Shield;
    }

    public boolean isWeapon()
    {
        return this == Weapon2;
    }

    public static ItemCategory valueOf(int id) throws IllegalArgumentException
    {
        for (ItemCategory itemCategory : values())
        {
            if (itemCategory.getId() == id)
            {
                return itemCategory;
            }
        }

        throw new IllegalArgumentException(id + " is not a valid ItemCategory");
    }
}
